package com.wwj.study.spring.demo.controller;

import com.wwj.study.spring.demo.service.ITestCustomNameService;
import com.wwj.study.spring.demo.service.ITestService;
import com.wwj.study.spring.formework.annotion.WAutowired;
import com.wwj.study.spring.formework.annotion.WController;
import com.wwj.study.spring.formework.annotion.WRequestMapping;
import com.wwj.study.spring.formework.annotion.WRequestParam;
import com.wwj.study.spring.formework.webmvc.WModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by lenovo on 2018/10/31.
 */

@WController
@WRequestMapping("test2")
public class Test2Controller {


    @WAutowired("wTestCustomNameService")
    private ITestCustomNameService testCustomNameService;


    @WRequestMapping(value = "/query.jhtml")
    public WModelAndView query(@WRequestParam("id") Integer id , @WRequestParam("name") String name, HttpServletResponse response, HttpServletRequest request) {

        Map<String,Object> model = new HashMap<String,Object>();
        model.put("id", id);
        model.put("name", name);
        model.put("token", testCustomNameService.getToken(id,name));

        //返回viewName名称，Map参数集合
        return new WModelAndView("first.jhtml",model);

    }
}
